<!DOCTYPE html><html lang="en" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Ywrby个人博客网站 - less is more</title><meta name="author" content="Ywrby"><meta name="copyright" content="Ywrby"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="Students majoring in CS at SWU">
<meta property="og:type" content="website">
<meta property="og:title" content="Ywrby个人博客网站">
<meta property="og:url" content="http://ywrby.cn/page/11/index.html">
<meta property="og:site_name" content="Ywrby个人博客网站">
<meta property="og:description" content="Students majoring in CS at SWU">
<meta property="og:locale" content="en_US">
<meta property="og:image" content="http://ywrby.cn/img/ywrby.png">
<meta property="article:author" content="Ywrby">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://ywrby.cn/img/ywrby.png"><link rel="shortcut icon" href="/img/title.png"><link rel="canonical" href="http://ywrby.cn/page/11/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: {"path":"search.xml","languages":{"hits_empty":"We didn't find any results for the search: ${query}"}},
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: 'Copy successfully',
    error: 'Copy error',
    noSupport: 'The browser does not support'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  date_suffix: {
    just: 'Just',
    min: 'minutes ago',
    hour: 'hours ago',
    day: 'days ago',
    month: 'months ago'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    jQuery: 'https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js',
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
    },
    fancybox: {
      js: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js',
      css: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isanchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'Ywrby个人博客网站',
  isPost: false,
  isHome: true,
  isHighlightShrink: false,
  isToc: false,
  postUpdate: '2021-12-25 18:42:00'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if (GLOBAL_CONFIG_SITE.isHome && /iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    document.addEventListener('pjax:complete', detectApple)})(window)</script><link rel="stylesheet" href="/css/background.css"><meta name="generator" content="Hexo 5.4.0"><link rel="alternate" href="/atom.xml" title="Ywrby个人博客网站" type="application/atom+xml">
</head><body><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="/img/ywrby.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data"><div class="data-item is-center"><div class="data-item-link"><a href="/archives/"><div class="headline">Articles</div><div class="length-num">127</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/tags/"><div class="headline">Tags</div><div class="length-num">22</div></a></div></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> Bilibili</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/bangumis/"><i class="fa-fw fas fa-video"></i><span> 追番列表</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://space.bilibili.com/353923033"><i class="fa-fw fas fa-music"></i><span> B站主页</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于我</span></a></div></div></div></div><div class="page" id="body-wrap"><header class="full_page" id="page-header" style="background-image: url('/img/back.jpg')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">Ywrby个人博客网站</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> Search</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> Bilibili</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/bangumis/"><i class="fa-fw fas fa-video"></i><span> 追番列表</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://space.bilibili.com/353923033"><i class="fa-fw fas fa-music"></i><span> B站主页</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于我</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="site-info"><h1 id="site-title">Ywrby个人博客网站</h1><div id="site-subtitle"><span id="subtitle"></span></div><div id="site_social_icons"><a class="social-icon" href="mailto:ywrby0214@gmail.com" target="_blank" title="Email"><i class="fas fa-envelope"></i></a><a class="social-icon" href="https://space.bilibili.com/353923033" target="_blank" title="Bilibili"><i class="fas fa-file-video"></i></a><a class="social-icon" href="http://wpa.qq.com/msgrd?v=3&amp;uin=2278431384&amp;site=qq&amp;menu=yes" target="_blank" title="QQ"><i class="fab fa-qq"></i></a><a class="social-icon" href="https://twitter.com/ywrby1" target="_blank" title="Twitter"><i class="fab fa-twitter"></i></a><a class="social-icon" href="https://www.facebook.com/profile.php?id=100033741068822" target="_blank" title="Facebook"><i class="fab fa-facebook"></i></a></div></div><div id="scroll-down"><i class="fas fa-angle-down scroll-down-effects"></i></div></header><main class="layout" id="content-inner"><div class="recent-posts" id="recent-posts"><div class="recent-post-item"><div class="post_cover left_radius"><a href="/2021/03/03/3-DOM/" title="3-DOM">     <img class="post_bg" src="/img/80857290_p0.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="3-DOM"></a></div><div class="recent-post-info"><a class="article-title" href="/2021/03/03/3-DOM/" title="3-DOM">3-DOM</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">Created</span><time datetime="2021-03-03T12:22:36.000Z" title="Created 2021-03-03 20:22:36">2021-03-03</time></span><span class="article-meta tags"><span class="article-meta__separator">|</span><i class="fas fa-tag"></i><a class="article-meta__tags" href="/tags/JavaScript/">JavaScript</a></span></div><div class="content">DOM(Document Object Model)文档对象模型
概念将标记语言文档（HTML,XML…）的各个部分，封装为对象，可以使用这些对象，对标记语言文档进行CRUD动态操作
W3C 文档对象模型 （DOM）是中立于平台和语言的接口，它允许程序和脚本动态地访问和更新文档的内容、结构和样式。”W3C DOM标准被分为 3 个不同的部分

核心DOM-针对任何结构化文档的标准模型
Document：文档对象
Element：元素对象
Attribute：属性对象
Text：文本对象
Comment：注释对象
Node：节点对象，是其他5个对象的父对象


XML DOM - 针对 XML 文档的标准模型
HTML DOM - 针对 HTML 文档的标准模型

HTML DOM 树

Document对象对象创建
window.document
document

方法获取Element对象

getElementById()    查找具有指定的唯一 ID 的元素。
getElementsByTagName()    返回所有具有指定名称的元素节点。
getElementByCla ...</div></div></div><div class="recent-post-item"><div class="post_cover right_radius"><a href="/2021/03/03/2-BOM/" title="2-BOM">     <img class="post_bg" src="/img/81691339_p0.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="2-BOM"></a></div><div class="recent-post-info"><a class="article-title" href="/2021/03/03/2-BOM/" title="2-BOM">2-BOM</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">Created</span><time datetime="2021-03-03T12:22:35.000Z" title="Created 2021-03-03 20:22:35">2021-03-03</time></span><span class="article-meta tags"><span class="article-meta__separator">|</span><i class="fas fa-tag"></i><a class="article-meta__tags" href="/tags/JavaScript/">JavaScript</a></span></div><div class="content">BOM(Browser Object Model)浏览器对象模型
概念将浏览器各个组成部分封装成对象
组成
Window：窗口对象
Navigator：浏览器对象
Screen：显示器屏幕对象
History：历史记录对象
Location：地址栏对象

(DOM对象因为十分重要被单独分类)
BOM对象组成
Window对象12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849/*Window窗口对象1. 创建2. 方法    1. 与弹出框相关的方法        alert()	显示带有一段消息和一个确认按钮的警告框。        confirm()	显示带有一段消息以及确认按钮和取消按钮的对话框。(确定返回true，取消返回false)        prompt()	显示可提示用户输入的对话框。 返回值即用户输入的值    2. 与打开关闭有关的方法        close()	关闭浏览器窗口。关闭的窗口是调用该方法的窗口        open()	 ...</div></div></div><div class="recent-post-item"><div class="post_cover left_radius"><a href="/2021/03/03/1-JavaScipt%E5%9F%BA%E7%A1%80%E6%A6%82%E5%BF%B5/" title="1-JavaScipt基础概念">     <img class="post_bg" src="/img/66150863_p0.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="1-JavaScipt基础概念"></a></div><div class="recent-post-info"><a class="article-title" href="/2021/03/03/1-JavaScipt%E5%9F%BA%E7%A1%80%E6%A6%82%E5%BF%B5/" title="1-JavaScipt基础概念">1-JavaScipt基础概念</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">Created</span><time datetime="2021-03-03T12:22:34.000Z" title="Created 2021-03-03 20:22:34">2021-03-03</time></span><span class="article-meta tags"><span class="article-meta__separator">|</span><i class="fas fa-tag"></i><a class="article-meta__tags" href="/tags/JavaScript/">JavaScript</a></span></div><div class="content">JavaScript概念一门客户端脚本语言（客户端指运行在客户端浏览器中，每一个浏览器都有JavaScript解析引擎。脚本语言指不需要通过编译，直接就可以被浏览器解析执行）
功能用来增强用户和HTML页面交互过程，可以控制HTML元素，让页面有一些动态的效果（与动态资源无关），增强用户体验
基本语法与HTML结合方式1. 内部JS通过定义标签实现，标签内容就是js代码。
2. 外部JS同样通过定义实现，通过src属性引入外部文件
实例：12345678910111213141516171819202122232425262728&lt;!DOCTYPE html&gt;&lt;html lang=&quot;en&quot;&gt;&lt;head&gt;    &lt;meta charset=&quot;UTF-8&quot;&gt;    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;    &lt;title&gt;Document ...</div></div></div><div class="recent-post-item"><div class="post_cover right_radius"><a href="/2021/03/03/15-%E5%88%9D%E5%A7%8B%E5%8C%96%E5%92%8C%E6%B8%85%E7%90%86/" title="15-初始化和清理">     <img class="post_bg" src="/img/68304874_p0.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="15-初始化和清理"></a></div><div class="recent-post-info"><a class="article-title" href="/2021/03/03/15-%E5%88%9D%E5%A7%8B%E5%8C%96%E5%92%8C%E6%B8%85%E7%90%86/" title="15-初始化和清理">15-初始化和清理</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">Created</span><time datetime="2021-03-03T05:59:25.000Z" title="Created 2021-03-03 13:59:25">2021-03-03</time></span><span class="article-meta tags"><span class="article-meta__separator">|</span><i class="fas fa-tag"></i><a class="article-meta__tags" href="/tags/Java/">Java</a></span></div><div class="content">初始化和清理初始化和清理是涉及编程安全的两个重要问题，在C语言中一直采取由程序员直接控制变量的初始化和清理，极易导致内存耗尽等问题出现
C++和Java采用了构造器（构造方法）的概念来进行对象的创建，创建对象时，如果该类提供有构造方法，Java会在用户有能力操作对象前调用构造器，完成对类中每个对象的初始化
构造器与类同名的原因
调用构造器是编译器的任务，所以编译器必须清楚要调用哪个方法，这就要求所有类的构造器必须具有相同的方法名
所取的任何名字都可能与类中原有的方法名重复，产生冲突，为了避免这种情况，统一采用构造器与类同名这种方案

构造器没有返回值，这与返回值为空null（void）具有很大区别，构造器本质上不会返回任何东西，我们在创建对象时Object object=new Object();看似是构造方法返回了一个新对象，实质是new表达式返回了该对象的引用（虽然与该对象完全一致）。
因为有了构造器的存在，所以强制重载方法名就显得十分重要，这也是Java支持强制重载方法名的重要原因。区分重载方法的唯一规则是不同的参数列表（即便只是顺序不同），而返回值并不可以作为区分重载方法的规则 ...</div></div></div><div class="recent-post-item"><div class="post_cover left_radius"><a href="/2021/03/03/14-IO%E6%B5%81/" title="14-IO流">     <img class="post_bg" src="/img/68304874_p0.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="14-IO流"></a></div><div class="recent-post-info"><a class="article-title" href="/2021/03/03/14-IO%E6%B5%81/" title="14-IO流">14-IO流</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">Created</span><time datetime="2021-03-03T05:59:24.000Z" title="Created 2021-03-03 13:59:24">2021-03-03</time></span><span class="article-meta tags"><span class="article-meta__separator">|</span><i class="fas fa-tag"></i><a class="article-meta__tags" href="/tags/Java/">Java</a></span></div><div class="content">字符集各个国家为自己国家的字符取的一套编号规则，计算机底层只能存储二进制，二进制可以转成十进制，十进制可以进行整数编号，所以计算机底层可以存储编号规则
I/O流的分类与概述（IO输入输出流-Input/Output）
File类只能操作文件对象本身，并不能操作文件的内容（对文件内容进行读/写）。如果需要读写数据的操作，就需要使用I/O流

I/O流的分类按照流的方向来分
输入流：已内存为基准，把内存中的数据写出到磁盘文件或者网络介质中去的流称为输入流。例如：将数据写入文件
输出流：以内存为基准，把磁盘文件中的数据或者网络中的数据读入到内存中去的流称为输入流。输入流的作用就是读取数据到内存

按照流的内容来分
字节流：流中的数据最小单位是一个一个的字节，这个流就是字节流
字符流：流中的数据最小单位是一个一个的字符，这个流就是字符流

FileInputStream-文件字节输入流以内存为基准，将磁盘文件中的数据按照字节的形式读入到内存中的流，简单来说，就是按照字节读取文件数据到内存构造器
public FileInputStream(File path):创建一个字节输入流管道与源文件对 ...</div></div></div><div class="recent-post-item"><div class="post_cover right_radius"><a href="/2021/03/03/13-%E9%80%92%E5%BD%92/" title="13-递归">     <img class="post_bg" src="/img/83821828_p0.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="13-递归"></a></div><div class="recent-post-info"><a class="article-title" href="/2021/03/03/13-%E9%80%92%E5%BD%92/" title="13-递归">13-递归</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">Created</span><time datetime="2021-03-03T05:59:23.000Z" title="Created 2021-03-03 13:59:23">2021-03-03</time></span><span class="article-meta tags"><span class="article-meta__separator">|</span><i class="fas fa-tag"></i><a class="article-meta__tags" href="/tags/Java/">Java</a></span></div><div class="content">递归概念递归指方法在方法中又调用自己递归形式直接递归自己的放大中调用自己
间接递归A方法调用B方法，B方法又调用A方法
递归三要素1. 一定有终止条件2. 递归的规则/公式3. 递归的方向：必然走向终止条件递归搜索文件12345678910111213141516171819202122232425package FileDemo;import java.io.File;public class FileDemo1 &#123;    public void findFile(File f)&#123;        if(f.isFile())&#123;            System.out.println(f.getName());        &#125;        else&#123;            System.out.println(&quot;文件夹----------------------&quot;+f.getName()+&quot;----------------------文件夹&quot;);            for(File f ...</div></div></div><div class="recent-post-item"><div class="post_cover left_radius"><a href="/2021/03/03/12-File%E7%B1%BB/" title="12-File类">     <img class="post_bg" src="/img/68304874_p0.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="12-File类"></a></div><div class="recent-post-info"><a class="article-title" href="/2021/03/03/12-File%E7%B1%BB/" title="12-File类">12-File类</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">Created</span><time datetime="2021-03-03T05:59:22.000Z" title="Created 2021-03-03 13:59:22">2021-03-03</time></span><span class="article-meta tags"><span class="article-meta__separator">|</span><i class="fas fa-tag"></i><a class="article-meta__tags" href="/tags/Java/">Java</a></span></div><div class="content">File类概述File类代表操作系统的文件对象，是用来操作操作系统中的文件对象的，例如：删除文件，获取文件信息，创建文件/文件夹。广义来说，操作系统认为文件已经包含了文件和文件夹的概念
构造器
public File(String pathname):根据路径获取文件对象
public File(String parent,String child):根据父路径和文件名称获取文件对象
public File(File parent,String child):根据父类文件对象和子类文件名称获取子类文件对象

这里的路径也是分为绝对路径和相对路径，Java默认的相对路径是相对工程目录下的文件路径。二者比较而言，绝对路径一旦脱离具体依赖的环境，代码就极可能出错。相对路径在脱离所处的环境后一般还是可以正常执行，但相对路径只能用于寻找该工程下的文件，有一定的局限性。一般为了跨平台操作，主要采用相对路径
文件路径分隔符
可以使用正斜杠“/”
使用反斜杠（需要转义）“\\”
使用分隔符API：File.separator

123456//方式1：使用正斜杠File f1=new File(&qu ...</div></div></div><div class="recent-post-item"><div class="post_cover right_radius"><a href="/2021/03/03/11-Stream%E6%B5%81/" title="11-Stream流">     <img class="post_bg" src="/img/72124553_p0.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="11-Stream流"></a></div><div class="recent-post-info"><a class="article-title" href="/2021/03/03/11-Stream%E6%B5%81/" title="11-Stream流">11-Stream流</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">Created</span><time datetime="2021-03-03T05:59:21.000Z" title="Created 2021-03-03 13:59:21">2021-03-03</time></span><span class="article-meta tags"><span class="article-meta__separator">|</span><i class="fas fa-tag"></i><a class="article-meta__tags" href="/tags/Java/">Java</a></span></div><div class="content">Stream流的概述概念得益于Lambda所带来的函数式编程，用于解决已有集合/数组类库有的弊端
用途解决已有集合类库或者数组API的弊端
实例1234567891011121314151617181920212223242526272829package StreamDemo;import java.util.ArrayList;import java.util.List;public class StreamDemo1 &#123;    public static void main(String[] args) &#123;        List&lt;String&gt; lists = new ArrayList&lt;&gt;();        lists.add(&quot;Leslie&quot;); lists.add(&quot;Lily&quot;); lists.add(&quot;Leon&quot;);        lists.add(&quot;John&quot;); lists.add(&quot;Li&quot;); lists.add(&q ...</div></div></div><div class="recent-post-item"><div class="post_cover left_radius"><a href="/2021/03/03/10-%E6%96%B9%E6%B3%95%E5%BC%95%E7%94%A8/" title="10-方法引用">     <img class="post_bg" src="/img/72175872_p0.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="10-方法引用"></a></div><div class="recent-post-info"><a class="article-title" href="/2021/03/03/10-%E6%96%B9%E6%B3%95%E5%BC%95%E7%94%A8/" title="10-方法引用">10-方法引用</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">Created</span><time datetime="2021-03-03T05:59:20.000Z" title="Created 2021-03-03 13:59:20">2021-03-03</time></span><span class="article-meta tags"><span class="article-meta__separator">|</span><i class="fas fa-tag"></i><a class="article-meta__tags" href="/tags/Java/">Java</a></span></div><div class="content">方法引用概述目的方法引用是为了进一步简化Lambda表达式的写法
格式1类型或对象::引用的方法  //关键语法  “::”


实例123456789101112131415161718package ComparatorDemo;import java.util.ArrayList;import java.util.List;public class MethodDemo &#123;    public static void main(String[] args) &#123;        List&lt;String&gt; lists=new ArrayList&lt;&gt;();        lists.add(&quot;first&quot;);        lists.add(&quot;second&quot;);        lists.add(&quot;third&quot;);        //遍历列表，通过Lambda表达式的方法        lists.forEach(s -&gt; System.out.println(s));     ...</div></div></div><div class="recent-post-item"><div class="post_cover right_radius"><a href="/2021/03/03/9-Lambda%E8%A1%A8%E8%BE%BE%E5%BC%8F/" title="9-Lambda表达式">     <img class="post_bg" src="/img/73870940_p0.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="9-Lambda表达式"></a></div><div class="recent-post-info"><a class="article-title" href="/2021/03/03/9-Lambda%E8%A1%A8%E8%BE%BE%E5%BC%8F/" title="9-Lambda表达式">9-Lambda表达式</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">Created</span><time datetime="2021-03-03T05:59:19.000Z" title="Created 2021-03-03 13:59:19">2021-03-03</time></span><span class="article-meta tags"><span class="article-meta__separator">|</span><i class="fas fa-tag"></i><a class="article-meta__tags" href="/tags/Java/">Java</a></span></div><div class="content">匿名内部类没有名字的局部内部类，匿名内部类的目的是为了简化代码。
格式123new 类名|抽象类|接口(形参)&#123;    方法重写......&#125;

实例12345678910111213141516171819202122232425package Anonymity;abstract class Task&#123;    public void func()&#123;        System.out.println(&quot;这是父类的func方法&quot;);    &#125;    //定义抽象方法    public abstract void func2();&#125;public class Demo1 &#123;    //匿名内部类    public static Task t=new Task() &#123;        //重写抽象方法        @Override        public void func2() &#123;            System.out.println(&quot;这是匿名内部类重 ...</div></div></div><nav id="pagination"><div class="pagination"><a class="extend prev" rel="prev" href="/page/10/#content-inner"><i class="fas fa-chevron-left fa-fw"></i></a><a class="page-number" href="/">1</a><span class="space">&hellip;</span><a class="page-number" href="/page/10/#content-inner">10</a><span class="page-number current">11</span><a class="page-number" href="/page/12/#content-inner">12</a><a class="page-number" href="/page/13/#content-inner">13</a><a class="extend next" rel="next" href="/page/12/#content-inner"><i class="fas fa-chevron-right fa-fw"></i></a></div></nav></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="/img/ywrby.png" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">Ywrby</div><div class="author-info__description">Students majoring in CS at SWU</div></div><div class="card-info-data"><div class="card-info-data-item is-center"><a href="/archives/"><div class="headline">Articles</div><div class="length-num">127</div></a></div><div class="card-info-data-item is-center"><a href="/tags/"><div class="headline">Tags</div><div class="length-num">22</div></a></div></div><a class="button--animated" id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/ywrby"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="mailto:ywrby0214@gmail.com" target="_blank" title="Email"><i class="fas fa-envelope"></i></a><a class="social-icon" href="https://space.bilibili.com/353923033" target="_blank" title="Bilibili"><i class="fas fa-file-video"></i></a><a class="social-icon" href="http://wpa.qq.com/msgrd?v=3&amp;uin=2278431384&amp;site=qq&amp;menu=yes" target="_blank" title="QQ"><i class="fab fa-qq"></i></a><a class="social-icon" href="https://twitter.com/ywrby1" target="_blank" title="Twitter"><i class="fab fa-twitter"></i></a><a class="social-icon" href="https://www.facebook.com/profile.php?id=100033741068822" target="_blank" title="Facebook"><i class="fab fa-facebook"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn card-announcement-animation"></i><span>Announcement</span></div><div class="announcement_content">Less is more</div></div><div class="sticky_layout"><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>Recent Post</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/2021/12/25/22-%E5%86%85%E5%AD%98%E7%A9%BA%E9%97%B4%E6%89%A9%E5%85%85%EF%BC%88%E8%A6%86%E7%9B%96%E4%B8%8E%E4%BA%A4%E6%8D%A2%EF%BC%89/" title="22-内存空间扩充（覆盖与交换）"><img src="/img/67888138_p0.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="22-内存空间扩充（覆盖与交换）"/></a><div class="content"><a class="title" href="/2021/12/25/22-%E5%86%85%E5%AD%98%E7%A9%BA%E9%97%B4%E6%89%A9%E5%85%85%EF%BC%88%E8%A6%86%E7%9B%96%E4%B8%8E%E4%BA%A4%E6%8D%A2%EF%BC%89/" title="22-内存空间扩充（覆盖与交换）">22-内存空间扩充（覆盖与交换）</a><time datetime="2021-12-25T08:15:49.000Z" title="Created 2021-12-25 16:15:49">2021-12-25</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/12/19/21-%E5%86%85%E5%AD%98%E4%B8%8E%E5%86%85%E5%AD%98%E7%AE%A1%E7%90%86/" title="21-内存与内存管理"><img src="/img/80857290_p0.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="21-内存与内存管理"/></a><div class="content"><a class="title" href="/2021/12/19/21-%E5%86%85%E5%AD%98%E4%B8%8E%E5%86%85%E5%AD%98%E7%AE%A1%E7%90%86/" title="21-内存与内存管理">21-内存与内存管理</a><time datetime="2021-12-19T09:57:53.000Z" title="Created 2021-12-19 17:57:53">2021-12-19</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/12/11/20-%E6%AD%BB%E9%94%81/" title="20-死锁"><img src="/img/81934649_p0.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="20-死锁"/></a><div class="content"><a class="title" href="/2021/12/11/20-%E6%AD%BB%E9%94%81/" title="20-死锁">20-死锁</a><time datetime="2021-12-11T06:20:20.000Z" title="Created 2021-12-11 14:20:20">2021-12-11</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/11/28/19-%E7%AE%A1%E7%A8%8B/" title="19-管程"><img src="/img/72581222_p0.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="19-管程"/></a><div class="content"><a class="title" href="/2021/11/28/19-%E7%AE%A1%E7%A8%8B/" title="19-管程">19-管程</a><time datetime="2021-11-28T08:39:08.000Z" title="Created 2021-11-28 16:39:08">2021-11-28</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/11/17/18-%E4%BF%A1%E5%8F%B7%E9%87%8F%E7%9B%B8%E5%85%B3%E9%97%AE%E9%A2%98%EF%BC%88%E5%90%B8%E7%83%9F%E8%80%85%EF%BC%8C%E8%AF%BB%E8%80%85-%E5%86%99%E8%80%85%E7%AD%89%EF%BC%89/" title="18-信号量相关问题（吸烟者，读者-写者等）"><img src="/img/73604608_p0.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="18-信号量相关问题（吸烟者，读者-写者等）"/></a><div class="content"><a class="title" href="/2021/11/17/18-%E4%BF%A1%E5%8F%B7%E9%87%8F%E7%9B%B8%E5%85%B3%E9%97%AE%E9%A2%98%EF%BC%88%E5%90%B8%E7%83%9F%E8%80%85%EF%BC%8C%E8%AF%BB%E8%80%85-%E5%86%99%E8%80%85%E7%AD%89%EF%BC%89/" title="18-信号量相关问题（吸烟者，读者-写者等）">18-信号量相关问题（吸烟者，读者-写者等）</a><time datetime="2021-11-17T12:08:38.000Z" title="Created 2021-11-17 20:08:38">2021-11-17</time></div></div></div></div><div class="card-widget card-tags"><div class="item-headline"><i class="fas fa-tags"></i><span>Tags</span></div><div class="card-tag-cloud"><a href="/tags/Docker/" style="font-size: 1.18em; color: #999ca1">Docker</a> <a href="/tags/Electron/" style="font-size: 1.1em; color: #999">Electron</a> <a href="/tags/JVM/" style="font-size: 1.1em; color: #999">JVM</a> <a href="/tags/Java/" style="font-size: 1.38em; color: #99a4b4">Java</a> <a href="/tags/JavaScript/" style="font-size: 1.18em; color: #999ca1">JavaScript</a> <a href="/tags/JavaWeb/" style="font-size: 1.5em; color: #99a9bf">JavaWeb</a> <a href="/tags/Lombok/" style="font-size: 1.1em; color: #999">Lombok</a> <a href="/tags/MyBatis/" style="font-size: 1.22em; color: #999ea4">MyBatis</a> <a href="/tags/MySQL/" style="font-size: 1.34em; color: #99a3b0">MySQL</a> <a href="/tags/P2P/" style="font-size: 1.1em; color: #999">P2P</a> <a href="/tags/Spring/" style="font-size: 1.46em; color: #99a7bb">Spring</a> <a href="/tags/SpringBoot/" style="font-size: 1.26em; color: #999fa8">SpringBoot</a> <a href="/tags/SpringMVC/" style="font-size: 1.3em; color: #99a1ac">SpringMVC</a> <a href="/tags/Swagger/" style="font-size: 1.1em; color: #999">Swagger</a> <a href="/tags/Vue/" style="font-size: 1.14em; color: #999b9d">Vue</a> <a href="/tags/Yaml/" style="font-size: 1.1em; color: #999">Yaml</a> <a href="/tags/tio/" style="font-size: 1.1em; color: #999">tio</a> <a href="/tags/%E5%8C%BA%E5%9D%97%E9%93%BE/" style="font-size: 1.14em; color: #999b9d">区块链</a> <a href="/tags/%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F/" style="font-size: 1.42em; color: #99a6b7">操作系统</a> <a href="/tags/%E6%BC%94%E5%8C%96%E5%8D%9A%E5%BC%88/" style="font-size: 1.1em; color: #999">演化博弈</a> <a href="/tags/%E7%AE%97%E6%B3%95/" style="font-size: 1.1em; color: #999">算法</a> <a href="/tags/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BD%91%E7%BB%9C/" style="font-size: 1.3em; color: #99a1ac">计算机网络</a></div></div><div class="card-widget card-archives"><div class="item-headline"><i class="fas fa-archive"></i><span>Archives</span></div><ul class="card-archive-list"><li class="card-archive-list-item"><a class="card-archive-list-link" href="/archives/2021/12/"><span class="card-archive-list-date">December 2021</span><span class="card-archive-list-count">3</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/archives/2021/11/"><span class="card-archive-list-date">November 2021</span><span class="card-archive-list-count">21</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/archives/2021/09/"><span class="card-archive-list-date">September 2021</span><span class="card-archive-list-count">4</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/archives/2021/07/"><span class="card-archive-list-date">July 2021</span><span class="card-archive-list-count">2</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/archives/2021/06/"><span class="card-archive-list-date">June 2021</span><span class="card-archive-list-count">3</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/archives/2021/05/"><span class="card-archive-list-date">May 2021</span><span class="card-archive-list-count">3</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/archives/2021/04/"><span class="card-archive-list-date">April 2021</span><span class="card-archive-list-count">16</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/archives/2021/03/"><span class="card-archive-list-date">March 2021</span><span class="card-archive-list-count">75</span></a></li></ul></div><div class="card-widget card-webinfo"><div class="item-headline"><i class="fas fa-chart-line"></i><span>Info</span></div><div class="webinfo"><div class="webinfo-item"><div class="item-name">Article :</div><div class="item-count">127</div></div><div class="webinfo-item"><div class="item-name">UV :</div><div class="item-count" id="busuanzi_value_site_uv"></div></div><div class="webinfo-item"><div class="item-name">PV :</div><div class="item-count" id="busuanzi_value_site_pv"></div></div><div class="webinfo-item"><div class="item-name">Last Push :</div><div class="item-count" id="last-push-date" data-lastPushDate="2021-12-25T10:41:59.790Z"></div></div></div></div></div></div></main><footer id="footer" style="background-image: url('/img/back.jpg')"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2021 By Ywrby</div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="darkmode" type="button" title="Switch Between Light And Dark Mode"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="Toggle between single-column and double-column"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="Setting"><i class="fas fa-cog fa-spin"></i></button><button id="go-up" type="button" title="Back To Top"><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><div class="search-dialog__title" id="local-search-title">Local search</div><div id="local-input-panel"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="Search for Posts" type="text"/></div></div></div><hr/><div id="local-search-results"></div><span class="search-close-button"><i class="fas fa-times"></i></span></div><div id="search-mask"></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="/js/search/local-search.js"></script><div class="js-pjax"><script>function subtitleType () {
  if (true) { 
    var typed = new Typed("#subtitle", {
      strings: "Less is more".split(","),
      startDelay: 300,
      typeSpeed: 150,
      loop: true,
      backSpeed: 50
    })
  } else {
    document.getElementById("subtitle").innerHTML = 'L'
  }
}

if (true) {
  if (typeof Typed === 'function') {
    subtitleType()
  } else {
    getScript('https://cdn.jsdelivr.net/npm/typed.js/lib/typed.min.js').then(subtitleType)
  }
} else {
  subtitleType()
}</script></div><div class="aplayer no-destroy" data-id="5402995011" data-server="netease" data-type="playlist" data-fixed="true" data-mini="true" data-listFolded="false" data-lrctype=0	data-order="random" data-preload="none" data-autoplay="true" muted></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js"></script><script src="https://cdn.jsdelivr.net/gh/metowolf/MetingJS@1.2/dist/Meting.min.js"></script><script src="https://cdn.jsdelivr.net/npm/pjax/pjax.min.js"></script><script>let pjaxSelectors = [
  'title',
  '#config-diff',
  '#body-wrap',
  '#rightside-config-hide',
  '#rightside-config-show',
  '.js-pjax'
]

if (false) {
  pjaxSelectors.unshift('meta[property="og:image"]', 'meta[property="og:title"]', 'meta[property="og:url"]')
}

var pjax = new Pjax({
  elements: 'a:not([target="_blank"])',
  selectors: pjaxSelectors,
  cacheBust: false,
  analytics: false,
  scrollRestoration: false
})

document.addEventListener('pjax:send', function () {

  // removeEventListener scroll 
  window.removeEventListener('scroll', window.tocScrollFn)
  window.removeEventListener('scroll', scrollCollect)

  typeof preloader === 'object' && preloader.initLoading()
  
  if (window.aplayers) {
    for (let i = 0; i < window.aplayers.length; i++) {
      if (!window.aplayers[i].options.fixed) {
        window.aplayers[i].destroy()
      }
    }
  }

  typeof typed === 'object' && typed.destroy()

  //reset readmode
  const $bodyClassList = document.body.classList
  $bodyClassList.contains('read-mode') && $bodyClassList.remove('read-mode')

})

document.addEventListener('pjax:complete', function () {
  window.refreshFn()

  document.querySelectorAll('script[data-pjax]').forEach(item => {
    const newScript = document.createElement('script')
    const content = item.text || item.textContent || item.innerHTML || ""
    Array.from(item.attributes).forEach(attr => newScript.setAttribute(attr.name, attr.value))
    newScript.appendChild(document.createTextNode(content))
    item.parentNode.replaceChild(newScript, item)
  })

  GLOBAL_CONFIG.islazyload && window.lazyLoadInstance.update()

  typeof chatBtnFn === 'function' && chatBtnFn()
  typeof panguInit === 'function' && panguInit()

  // google analytics
  typeof gtag === 'function' && gtag('config', '', {'page_path': window.location.pathname});

  // baidu analytics
  typeof _hmt === 'object' && _hmt.push(['_trackPageview',window.location.pathname]);

  typeof loadMeting === 'function' && document.getElementsByClassName('aplayer').length && loadMeting()

  // Analytics
  if (false) {
    MtaH5.pgv()
  }

  // prismjs
  typeof Prism === 'object' && Prism.highlightAll()

  typeof preloader === 'object' && preloader.endLoading()
})

document.addEventListener('pjax:error', (e) => {
  if (e.request.status === 404) {
    pjax.loadUrl('/404.html')
  }
})</script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>